def compare (card1,card2):
n1=0
n2=0
if card1>"5" and card1<="9":
n1=int(card1)
if card2>"5" and card2<="9":
n2=int(card2)
if card1=="A":
n1=100
if card1=="K":
n1=90
if card1=="Q":
n1=80
if card1=="J":
n1=70
if card1=="T":
n1=60
if card2=="A":
n2=100
if card2=="K":
n2=90
if card2=="Q":
n2=80
if card2=="J":
n2=70
if card2=="T":
n2=60
return n1>n2
trump=input()
trump=str(trump)
cards= input()
cards= str (cards)
card1=cards.split(" ") [0]
card1=str(card1)
check1= card1[1]
check01= card1[0]
card2=cards.split(" ") [1]
card2=str(card2)
check2= card2[1]
check02= card2[0]
if check1==check2 and compare(check01,check02):
print("YES")
elif check1!=trump and check2==trump:
print("NO")
elif check1==trump and check2!=trump:
print("YES")
else:
print("NO")
#include <bits/stdc++.h>
using namespace std;
int main()
{
char trump;
char suit1, rank1, suit2, rank2;
cin >> trump;
cin >> rank1 >> suit1;
cin >> rank2 >> suit2;
if (suit1 == trump && suit2 != trump)
{
cout << "YES" << endl;
}
else if (suit1 != trump && suit2 == trump)
{
cout << "NO" << endl;
}
else
{
if (suit1 == suit2)
{
if (rank1 == 'A' && rank2 != 'A')
{
cout << "YES" << endl;
}
else if (rank1 == 'K' && (rank2 != 'A' && rank2 != 'K'))
{
cout << "YES" << endl;
}
else if (rank1 == 'Q' && (rank2 != 'A' && rank2 != 'K' && rank2 != 'Q'))
{
cout << "YES" << endl;
}
else if (rank1 == 'J' && (rank2 != 'A' && rank2 != 'K' && rank2 != 'Q' && rank2 != 'J'))
{
cout << "YES" << endl;
}
else if (rank1 == 'T' && (rank2 != 'A' && rank2 != 'K' && rank2 != 'Q' && rank2 != 'J' && rank2 != 'T'))
{
cout << "YES" << endl;
}
else if (rank1 >= '6' && rank1 <= '9' && rank2 >= '6' && rank2 <= '9')
{
if (rank1 > rank2)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
else
{
cout << "NO" << endl;
}
}
else
{
cout << "NO" << endl;
}
}
}
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |